home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tags18.zip / ARGLIST.H < prev    next >
C/C++ Source or Header  |  1991-09-25  |  4KB  |  126 lines

  1. /*
  2.  EPSHeader
  3.  
  4.    File: arglist.h
  5.    Author: J. Kercheval
  6.    Created: Thu, 09/05/1991  20:03:53
  7. */
  8. /*
  9.  EPSRevision History
  10.  
  11.    J. Kercheval  Thu, 09/05/1991  20:09:57  creation
  12.    J. Kercheval  Thu, 09/05/1991  21:47:54  add DestroyArgList()
  13.    J. Kercheval  Wed, 09/11/1991  00:19:12  add ArgCopy()
  14.    J. Kercheval  Wed, 09/25/1991  13:11:35  add sorted support
  15. */
  16.  
  17. /*
  18.  * This module implements a dynamically allocated argument list in the format
  19.  * used by the startup code in C.  Since this is dynamically increased as new
  20.  * arguments are registered, this is a good way to keep track of unsorted
  21.  * lists and to generate list to use as inputs to modules originally intended
  22.  * as standalone utilities.  This module is very naive about running out of
  23.  * memory.  If an out of memory error occurs, processing is halted via
  24.  * external_cleanup() (an external) and an exit(1).  Sorted list processing
  25.  * is done if the sorted BOOLEAN is true in the arglist.  These routines
  26.  * assume and maintain a list with unique elements if the list is sorted.
  27.  * all elements are string elements which are assumed to be non case
  28.  * sensitive.
  29.  */
  30.  
  31. #ifndef ARGLIST_HEADER
  32. #define ARGLIST_HEADER
  33.  
  34. #ifndef BOOLEAN
  35. #define BOOLEAN int
  36. #define TRUE 1
  37. #define FALSE 0
  38. #endif
  39.  
  40. #define ARGLIST_SORTED TRUE
  41. #define ARGLIST_NORMAL FALSE
  42.  
  43.  
  44. /* file argument list structure */
  45. struct ArgListStruct {
  46.     char **argv;                /* file list array */
  47.     unsigned int size;          /* number of array entries */
  48.     unsigned int num_files;     /* number of files in array */
  49.     unsigned int num_args;      /* number of elements in the array */
  50.     BOOLEAN sorted;             /* true if arglist is a sorted list */
  51. };
  52.  
  53. /* file argument list typedef */
  54. typedef struct ArgListStruct *ArgList;
  55.  
  56.  
  57. /*----------------------------------------------------------------------------
  58.  *
  59.  * CreateArgList() will allocate the memory needed for the use of an ArgList
  60.  * variable and will set the initial values of the list.  If sorted_list is
  61.  * TRUE then the list is maintained in sorted order when additions are made
  62.  * through the register arg routines.
  63.  *
  64.  ---------------------------------------------------------------------------*/
  65.  
  66. ArgList CreateArgList(BOOLEAN sorted_list);
  67.  
  68.  
  69. /*----------------------------------------------------------------------------
  70.  *
  71.  * DestroyArgList() will deallocate the memory used by the ArgList variable.
  72.  *
  73.  ---------------------------------------------------------------------------*/
  74.  
  75. void DestroyArgList(ArgList arglist);
  76.  
  77.  
  78. /*----------------------------------------------------------------------------
  79.  *
  80.  * ArgToOutputStream() will output all files in argv to stdout
  81.  *
  82.  ---------------------------------------------------------------------------*/
  83.  
  84. void ArgToOutputStream(FILE * output_file, ArgList arglist);
  85.  
  86.  
  87. /*----------------------------------------------------------------------------
  88.  *
  89.  * ArgIsMember() returns true if s is a member of the string array arg
  90.  *
  91.  ---------------------------------------------------------------------------*/
  92.  
  93. BOOLEAN ArgIsMember(ArgList arglist, char *arg);
  94.  
  95.  
  96. /*----------------------------------------------------------------------------
  97.  *
  98.  * ArgCopy() copies all the elements of argfrom to argto while adding
  99.  * internal bookkeeping variables
  100.  *
  101.  ---------------------------------------------------------------------------*/
  102.  
  103. void ArgCopy(ArgList argto, ArgList argfrom);
  104.  
  105.  
  106. /*----------------------------------------------------------------------------
  107.  *
  108.  * ArgRegisterArg() places an argument in the ArgList array and increments
  109.  * arglist->num_args
  110.  *
  111.  ---------------------------------------------------------------------------*/
  112.  
  113. void ArgRegisterArg(ArgList arglist, char *arg);
  114.  
  115.  
  116. /*----------------------------------------------------------------------------
  117.  *
  118.  * ArgRegister_name() place a file name into the ArgList array for later post
  119.  * processing and increments arglist->num_files and arglist->num_args
  120.  *
  121.  ---------------------------------------------------------------------------*/
  122.  
  123. void ArgRegisterName(ArgList arglist, char *name);
  124.  
  125. #endif                          /* ARGLIST_HEADER */
  126.